#ifndef __COMMAND_H__
#define __COMMAND_H__
#define PATHSTACK_MAXSIZE 1024
#define PATHNAME_MAXLEN 50
#define BUFSIZE 4096
/* #include "../server/head.h" */
#include "../server/include/head.h"// temp
#include <syslog.h>
#include <errno.h>
// 检错，输出到日志
#define LOG_ERRORCHECK(ret,err_flag,msg)\
    do{\
        if(ret == err_flag){\
            syslog(LOG_ERR,"log>%s: %s\n",msg,strerror(errno));\
        }\
    }while(0)
// 记录警告信息
#define LOG_WARNING_RECORD(msg)\
    do{\
        syslog(LOG_WARNING,"log>%s\n",msg);\
    }while(0)
// 记录操作和时间
#define LOG_INFO_RECORD(msg)\
    do{\
        time_t timeNow=time(NULL);\
        char buf[100] = {0};\
        syslog(LOG_INFO,"log>%s: %s\n",ctime_r(&timeNow,buf),msg);\
    }while(0)

int getFormattedPath (MYSQL *mysql,char*srcPath,char* destPath,int pathId,char* destFileName);
// 线程维护一个当前客户端的访问路径 int pathId
int my_cd (MYSQL *mysql, char* path,int *pathId,char *result);//path 是客户端发的原始参数数据
int my_ls(MYSQL *mysql, char* path,int pathId,char* result);
int my_pwd(MYSQL *mysql, int pathId,char* result);
int removeFile(MYSQL *mysql, char* path,int pathId,char *result,char *phyPath);
int removeDir(MYSQL *mysql, char* path,int pathId,char *result);
int my_mkdir(MYSQL *mysql, char* path,int pathId,char *result);
// 将上传的文件元数据添加到表中，如果同路径有同名文件，则在新文件名后面加(1)
int my_puts(MYSQL *mysql, char* path,int pathId,char* hashName);
//gets 客户端实现
int my_gets(MYSQL *mysql, char *path,int pathId,char* absPath,char *phyPath);

#endif
